# -*- coding: utf-8 -*-
"""
@Time ： 2024/3/30 8:00
@Auth ： fcq
@File ：data_statistic_analysis.py
@IDE ：PyCharm
@Motto：ABC(Always Be Coding)
"""

import json
from collections import Counter

idx2stance = {0: 'con', 1: 'pos', 2: 'neutral'}
idx2senti = {0: 'negative', 1: 'positive', 2: "neutral"}


def statistic_data(data_path):
    with open(data_path, 'r', encoding='utf-8') as f:
        data = json.load(f)

    # 统计数据
    data = [d for d in data if d['cross_senti'] == 0]

    # label_list = [idx2stance[d['label']] for d in data if d['seen'] == 0]
    label_list = [idx2stance[d['label']] for d in data]

    senti_list = [idx2senti[d['senti_score']] for d in data]
    # cross_label = [d['cross_label'] for d in data]
    # cross_label_new = [d['cross_label_new'] for d in data]
    senti_cross_label = [d['cross_senti'] for d in data]
    # senti_cross = [1 if data[i]['cross_senti'] == data[i]['cross_label_new'] else 0 for i in range(len(data))]
    # split_labels = [d['split_label'] for d in data]
    print("label's distribution: ", Counter(label_list))
    print("sentiment's distribution: ", Counter(senti_list))
    # print("cross label's distribution: ", Counter(cross_label))
    # print('cross label new distribution: ', Counter(cross_label_new))
    print("cross sentiment's distribution: ", Counter(senti_cross_label))
    # print("distribution of sentiment eq cross label: ", Counter(senti_cross))
    # print('distribution of split labels:', Counter(split_labels))


if __name__ == '__main__':
    statistic_data(data_path='../VAST/vast_dev_cross_senti_mask.json')
